﻿namespace Microsoft.SharePoint.Client
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;

    [ScriptType("SP.FormCollection", ServerTypeId="{078611ea-ce4d-45c0-9b7a-d4b1b46cc327}")]
    public class FormCollection : ClientObjectCollection<Form>
    {
        [EditorBrowsable(EditorBrowsableState.Never)]
        public FormCollection(ClientRuntimeContext Context, ObjectPath ObjectPath) : base(Context, ObjectPath)
        {
        }

        [Remote]
        public Form GetByPageType(PageType formType)
        {
            Dictionary<PageType, Form> dictionary;
            object obj2;
            if (base.ObjectData.MethodReturnObjects.TryGetValue("GetByPageType", out obj2))
            {
                dictionary = (Dictionary<PageType, Form>) obj2;
            }
            else
            {
                dictionary = new Dictionary<PageType, Form>();
                base.ObjectData.MethodReturnObjects["GetByPageType"] = dictionary;
            }
            Form form = null;
            if (!dictionary.TryGetValue(formType, out form))
            {
                form = new Form(base.Context, new ObjectPathMethod(base.Context, base.Path, "GetByPageType", new object[] { formType }));
                dictionary[formType] = form;
            }
            return form;
        }

        protected override bool InitOnePropertyFromJson(string peekedName, JsonReader reader)
        {
            bool flag = base.InitOnePropertyFromJson(peekedName, reader);
            if (flag)
            {
                return flag;
            }
            return flag;
        }
    }
}

